#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <limits.h>

void
print_bin(int n)
{
	register int i = 31;
	while (i >= 0)
		fprintf(stderr, "%d", abs((n>>i--) % 2));
	fputc('\n', stderr);
}

int
f(int x)
{
	register int i;
	int even = 0, odd = 0;
	int ans = 0;

	for (i = 0; i < sizeof x * CHAR_BIT - 1; i += 2) {
		if ((x >> i) & 01)
			even++;
		if ((x >> i) & 02)
			odd++;
	}

	for (i = 0; i < sizeof x * CHAR_BIT; i += 2) {
		if (even-- > 0)
			ans |= 01 << i;
		if (odd-- > 0)
			ans |= 02 << i;
	}

	return ans;
}

int
main(int argc, char **argv)
{
	int x;

	scanf("%d", &x);
	printf("%d\n", f(x));

	return 0;
}
